package yifeng.program;

import yifeng.program.utils.Utils;

public class SelectSort {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		int[] a = Utils.createIntArray(10, 1, 10);
		Utils.printArray(a);
		selectSort(a);
		Utils.printArray(a);
	}
	
	public static void selectSort(int[] a){
		if(a.length <= 0)
			return;
		int indexOfTheBiggestNumber;
		int i,j;
		for(i = 0; i < a.length - 1; i++){
			indexOfTheBiggestNumber = 0;
			for(j = 0; j < a.length - i; j++){
				if(a[j] > a[indexOfTheBiggestNumber])
					indexOfTheBiggestNumber = j;
			}
			Utils.swap(a, indexOfTheBiggestNumber, j - 1);
		}
	}
	

}
